using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class Management_JobSeekerAccount : System.Web.UI.Page
{
    string connectionString = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["aduserid"] == null)
            Response.Redirect("login.aspx");
        connectionString =
         WebConfigurationManager.ConnectionStrings[
           "RecruitVietnam"].ConnectionString;
        RegisterJavaScript();
        if (!IsPostBack)
        {
            string account = Request.QueryString.Get("UserID");
            SqlServerProvider sqlServerProvider = new SqlServerProvider();
            sqlServerProvider.ConnectionString = connectionString;

            sqlServerProvider.ParameterCollection = new string[1] { "@UserID" };
            sqlServerProvider.ValueCollection = new string[1] { account };
            sqlServerProvider.CommandText = "select * from tblJSAccounts where UserID=@UserID";
            DataTable dataTable = sqlServerProvider.GetDataTable();
            this.DetailsView1.DataSource = dataTable;
            this.DetailsView1.DataBind();
        }
    }
    void RegisterJavaScript()
    {
        Common common = new Common();
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "openWindow" + this.DetailsView1.ID, common.CreateScriptForPrint(this.DetailsView1.ID));
        this.btnPrint.Attributes.Add("onclick", "openWindow" + this.DetailsView1.ID + "('" + DetailsView1.ID.ToString() + "',400,700);return false;");
        btnBack.Attributes.Add("onclick", "window.history.go(-1);return false;");
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            string deleteQuery = "";
            string itemID = this.DetailsView1.Rows[0].Cells[1].Text;
            if (itemID != "")
            {

                deleteQuery = "delete from " +
                                "tblJSAccounts where UserID =" +
                                itemID;
                RecruitVietnam rcv
                            = new RecruitVietnam();
                rcv.ConnectionString =
                connectionString;
                if (!rcv.ExecuteSQL(deleteQuery))
                    litError.Text = rcv.ErrorMessage;
                else
                    Response.Redirect("JobSeekerAccounts.aspx");
            }
        }
        catch (Exception ex)
        {
            litError.Text = ex.Message;
        }
    }
}
